package com.yuanyu.controller.main;

import com.yuanyu.common.util.ResultInfoUtil;
import com.yuanyu.model.vo.MainVO;
import com.yuanyu.model.vo.ProcessVO;
import com.yuanyu.model.vo.ResultInfo;
import com.yuanyu.server.IMainServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/main")
public class MainController {
    @Autowired
    private IMainServer mainServer;

    @GetMapping("/selAll")
    public ResultInfo selAll(){
        return ResultInfoUtil.buildSuccess(mainServer.TotalNumberOfQueriedData());
    }

    @GetMapping("/selPage/{page}")
    public ResultInfo selPage(@PathVariable("page") Integer page){
        return ResultInfoUtil.buildSuccess(mainServer.mains(page));
    }
    @PostMapping("/selFuzzyAll")
    public ResultInfo selFuzzyAll(@RequestBody MainVO mainVO){
        return ResultInfoUtil.buildSuccess(mainServer.TotalFuzzyNumberOfQueriedData(mainVO));
    }

    @PostMapping("/selFuzzyPage/{page}")
    public ResultInfo selFuzzyPage(@RequestBody MainVO mainVO, @PathVariable("page") Integer page){
        return ResultInfoUtil.buildSuccess(mainServer.fuzzyMains(mainVO,page));
    }
    //查工序
    @GetMapping("/process/{case}")
    public ResultInfo selByCaseProcess(@PathVariable("case") String Case){
        return ResultInfoUtil.buildSuccess(mainServer.process(Case));
    }
    //工序更新
    @PostMapping("/updateProcess")
    public ResultInfo updateByCaseProcess(@RequestBody ProcessVO processVO){
        return ResultInfoUtil.buildSuccess(mainServer.updateProcess(processVO));
    }
    //结单
    @GetMapping("/statements/{case}")
    public ResultInfo updateByCaseStatements(@PathVariable("case") String Case){
        return ResultInfoUtil.buildSuccess(mainServer.statements(Case));
    }
    //强制结单
    @GetMapping("/mandatoryStatements/{case}")
    public ResultInfo updateByCaseMandatoryStatements(@PathVariable("case") String Case){
        return ResultInfoUtil.buildSuccess(mainServer.MandatoryStatements(Case));
    }

}
